package io.adrainty.bolee.insurance.service.impl;

import cn.hutool.core.collection.CollUtil;
import io.adrainty.bolee.insurance.models.entity.InsuranceCoefficientEntity;
import io.adrainty.bolee.insurance.repository.IInsuranceRepository;
import io.adrainty.bolee.insurance.service.IInsuranceCoefficientService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>InsuranceCoefficientServiceImpl</p>
 *
 * @author AdRainty
 * @version V1.0.0
 * @description InsuranceCoefficient
 * @since 2025/8/15 15:47:39
 */

@Service
public class InsuranceCoefficientServiceImpl implements IInsuranceCoefficientService {

    @Resource
    private IInsuranceRepository insuranceRepository;

    @Override
    public Boolean createInsuranceCoefficients(List<InsuranceCoefficientEntity> insuranceCoefficientVOs) {
        insuranceRepository.createInsuranceCoefficients(insuranceCoefficientVOs);
        return Boolean.TRUE;
    }

    @Override
    public Boolean updateInsuranceCoefficent(List<InsuranceCoefficientEntity> insuranceCoefficientVOs) {
        if (CollUtil.isEmpty(insuranceCoefficientVOs)) return Boolean.TRUE;
        Long insuranceId = insuranceCoefficientVOs.get(0).getInsuranceId();
        insuranceRepository.deleteInsuranceCoefficientByInsuranceId(insuranceId);
        insuranceRepository.createInsuranceCoefficients(insuranceCoefficientVOs);
        return Boolean.TRUE;
    }

    @Override
    public List<InsuranceCoefficientEntity> findList(InsuranceCoefficientEntity findDTO) {
        return insuranceRepository.findCoefficientList(findDTO);
    }
}
